<div class="wrapper activity-box">
    <empty name="openInfo">
        <div class="activity-process">
        	盒子不存在，自己领取一个吧~
        </div>
    <else />
        <div class="activity-box-container">
            <img id="box-img" src="__STYLE__/Box/images/box{$openInfo.boxId}.png">
        </div>
        <div class="activity-process">
            您的朋友 <span>{$openInfo.nickname}</span> 请您帮ta拆盒子。ta还差 <span>{$openInfo.diff}</span> 位朋友帮忙就可以打开盒子赢取礼品了，快点帮帮ta吧！
        </div>
    </empty>
    
</div>

<div class="wrapper activity-action">
    <a id="btn-open" class="button button-block button-rounded button-flat-royal">帮朋友拆盒子</a>
    <empty name="hostInfo">
        <a id="btn-get" href="__CONTROLLER__/index/cid/{$activity.cid}/aid/{$activity.id}/debug/{$Think.get.debug}" class="button button-block button-rounded button-flat-caution">我也要领取盒子</a>
    <else />
        <a id="btn-get" href="__CONTROLLER__/myBox/cid/{$activity.cid}/aid/{$activity.id}/debug/{$Think.get.debug}" class="button button-block button-rounded button-flat-caution">查看我的盒子</a>
    </empty>
</div>

<script type="text/javascript">
    $(function() {
        $("#btn-open").click(function() {
            $.ajax({
            	type:"POST",
            	url:"__CONTROLLER__/ajaxOpenBox?debug",
            	async:true,
            	data:{
            	    uid: userInfo.id,
            	    cid: "{$openInfo.cid}",
            	    aid: "{$openInfo.aid}",
            	    hid: "{$openInfo.id}"
            	},
            	beforeSend: function(){
            	    simapp.toast('正在帮助朋友拆盒子……');
            	},
            	success: function(res){
            	    simapp.toast(res.msg);
            	    if(res.state==1){
            	        location.href = "__CONTROLLER__/index/cid/{$activity.cid}/aid/{$activity.id}/debug/{$Think.get.debug}"
            	    }
            	},
            	error: function(){
            	    simapp.toast("网络不太好哦， 请过会再试~！");
            	}
            });
        });
    });
</script>
